<template>
    <div class="container">
        <EditTableCommon :prop-json="propJson" :common-param="commonParam" :table-data="tableData.variableValue"/>
    </div>
</template>

<script name="EditableTableListComponent" lang="ts" setup>
import EditTableCommon from '@/components/lowcode/extension/components/EditTableCommon.vue'
import {getCommonParamInfo, getCommonParamObj} from "@/utils/commonParamUtil";
import {computed, defineProps} from "vue";

let props = defineProps(['propJson', 'commonParam']);
let propJson = computed(() => {return props['propJson']})
let commonParam = computed(() => {return props['commonParam']})

let tableData = computed(() => {
    if (propJson.value.editFlag) {
        return []
    }
    let dataList = getCommonParamInfo(commonParam.value, propJson.value.tableDataVariable)
    // 为每一行数据添加一个序号
    for (let index = 0; index < dataList.length; index++) {
        let info = dataList[index]
        info["ywuEditorInnerId"] = index + 1;
    }
    let paramObj = getCommonParamObj(commonParam.value, propJson.value.tableDataVariable);
    if (!dataList) {
        paramObj.variableValue = [];
        return paramObj
    }
    paramObj.variableValue = dataList
    return paramObj;
})
</script>

<style scoped lang="less">

</style>